package models;

import java.util.HashSet;
import java.util.Set;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import static javax.persistence.GenerationType.IDENTITY;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;

import play.db.jpa.Model;

@Entity
@Table(name = "product")
public class Product extends Model {

	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "types_id")
	public Types types;
	
	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "company_id")
	public Company company;
	
	@Column(name = "name")
	public String name;
	
	@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "product")
	public Set<Sale> sales = new HashSet<Sale>(0);
	
	@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "product")
	public Set<TradeProductList> tradeproductlists = new HashSet<TradeProductList>(0);

	
	
	public Product() {
	}

	public Product(Types types, Company company, String name, Set<Sale> sales, Set<TradeProductList> tradeproductlists) {
		this.types = types;
		this.company = company;
		this.name = name;
		this.sales = sales;
		this.tradeproductlists = tradeproductlists;
	}

}